package com.javaweb.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.javaweb.constant.SystemConstant;

/**
 * 接口限流过滤器配置
 * @author tank2140896
 */
@Configuration
public class InterfaceLimitFilterConfig {
	
    /**
     * 过滤器注入
     * @return FilterRegistrationBean<InterfaceLimitFilter> FilterRegistrationBean<InterfaceLimitFilter>
     * @Link InterfaceLimitFilter
     */
	@Bean
    public FilterRegistrationBean<InterfaceLimitFilter> interfaceLimitFilter() {
        FilterRegistrationBean<InterfaceLimitFilter> bean = new FilterRegistrationBean<>();
        bean.setFilter(new InterfaceLimitFilter());
        bean.addUrlPatterns(SystemConstant.URL_ALL_PATTERN);
        bean.setName(InterfaceLimitFilter.class.getSimpleName());//InterfaceLimitFilter
        bean.setOrder(1);//数字越小处理优先级越高
        return bean;
    }

}
